package com.ee.chat.admin.controller.usermanage;

import com.ee.chat.admin.service.IVipService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("vip")
public class VipController {
    private Logger log = LoggerFactory.getLogger(VipController.class);

    @Resource
    IVipService vipService;

    /**
     * 获取用户信息列表
     * @Author Shane
     * @Date 2019/9/1110:35
     * @return
     **/
    @RequestMapping("list")
    public Result list(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit, String keyword, String createTime){
        try {
            return vipService.list(request, page, limit, keyword, createTime);
        } catch (Exception e){
            log.error("【获取会员信息列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 添加会员
     * @Author Shane
     * @Date 2020/4/30 15:21
     * @param
     * @return
     */
    @RequestMapping("add")
    public Result add(HttpServletRequest request, @RequestParam Integer userId, @RequestParam Integer identity){
        try {
            return vipService.add(request, userId, identity);
        } catch (Exception e){
            log.error("【新增会员错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 删除会员
     * @Author AppiJ
     * @Date 2021/3/1 11:12
     * @param
     * @return
     */
    @RequestMapping("del")
    public Result del(HttpServletRequest request, @RequestParam("ids[]") List<Integer> ids){
        try{
            return vipService.del(request, ids);
        }catch (Exception e){
            log.error("【删除会员错误】", e);
        }
        return Result.returnFailure();
    }
}
